package com.example.commons.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.filter.OncePerRequestFilter;

@Configuration
public class FilterRegistration {
    @Bean
    public FilterRegistrationBean<OncePerRequestFilter> servletFilter() {
        FilterRegistrationBean<OncePerRequestFilter> filter = new FilterRegistrationBean<>();
        filter.setFilter(new ServletFilter());
        filter.addUrlPatterns("/*");
        filter.setName("ServletFilter");
        filter.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return filter;
    }
}
